﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace YJKRevitAxisModule
{
	public class AxisDataGridViewRowHeaderCellEx : DataGridViewRowHeaderCell
	{
		protected override void Paint(Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
		{
			base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
			if (base.OwningRow == null)
			{
				return;
			}
			DataGridView dataGridView = base.DataGridView;
			if (dataGridView == null)
			{
				return;
			}
			if (dataGridView.RowCount == rowIndex + 1)
			{
				System.Drawing.Color white = System.Drawing.Color.White;
				System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(cellBounds.X + 1, cellBounds.Y, cellBounds.Width - 2, cellBounds.Height - 1);
				graphics.FillRectangle(new SolidBrush(white), rectangle);
				graphics.DrawRectangle(new Pen(dataGridView.GridColor), rectangle);
				TextRenderer.DrawText(graphics, "+", dataGridView.Font, rectangle, System.Drawing.Color.Black);
			}
		}
	}
}
